<?php

/**
 * User login form
 *
 */
class Application_Form_Login extends Zend_Form
{

    public function init()
    {
        $this->setMethod('POST');
        $this->setAction(Zend_Registry::get('view')->fixUrl('user/login'));
        
        $login=new Zend_Form_Element_Text('login');
        $login->setLabel('Login')
              ->addFilter('StringTrim')
              ->addValidator('StringLength', 
                              true, 
                              array(
                                    'min' => 4,
                                    'max'=> 255
                                    )
                              )
               ->addDecorator(new Application_Form_LoginDecorator())
               ->setRequired(true);
               
        $password=new Zend_Form_Element_Password('password');
        $password->setLabel('Password')
                 ->addFilter('StringTrim')
                 ->addValidator('StringLength', 
                              true, 
                              array(
                                    'min' => 5,
                                    'max'=> 255
                                    )
                              )
               ->addDecorator(new Application_Form_LoginDecorator())
               ->setRequired(true);
               
         $submit=new Zend_Form_Element_Submit('submit');
         $submit->setValue('Sign In')
                ->setLabel('')
                ->addDecorator(new Application_Form_LoginDecorator());
               
         $csrf=new Zend_Form_Element_Hash('csrf',array('salt' => 'userLogin'));
         $csrf->setOptions(array(
                            'ignore' => true,
                        ))
              ->addDecorator(new Application_Form_LoginDecorator());
        
         $this->addElements(array(
            $login,
            $password,
            $submit,
            $csrf
         ));                               
    }


}

